<?php
/**
 * Created by PhpStorm.
 * User: ewen
 * Date: 2/6/21
 * Time: 4:06 PM
 */

namespace app\api\controller\v1;


use app\api\controller\Base;
use app\common\model\AssetFlow;
use app\common\model\PartnerAccount;
use app\common\model\WebAssetAccount;
use app\common\model\WebUser;
use app\common\model\XkNormalText;
use app\common\model\XkSignRecord;
use app\common\model\XkUserTypeTask;

class Index extends Base
{

    public function index()
    {
        backSuccess('welcome v1');
    }

    public function index2()
    {
        backSuccess('v1 index2');
    }

    /**
     * 获取用户指定币种余额（获取TXUSD直接传TXUSD）
     */
    public function getUserTxusdAmount()
    {
        $coinSymbol = I('coinSymbol/s', '');//币种标识
        backSuccess(WebAssetAccount::getUserCoinAmount($coinSymbol, $this->uid));
    }

    /**
     * 查看用户今日是否已签到
     */
    public function hasSigned()
    {
        backSuccess(XkSignRecord::hasSigned($this->uid));
    }

    /**
     * 新增用户签到记录
     */
    public function addSign()
    {
        XkSignRecord::addSignRecord($this->uid);
    }

    /**
     * 领取攻略
     */
    public function getText()
    {
        backSuccess(XkNormalText::getTextByCode('gonglue', $this->lang));
    }

    /**
     * 获取用户任务
     */
    public function getUserTask()
    {
        $userInfo = WebUser::get($this->uid);
        !$userInfo && backError(lang('invalid user'));
        backSuccess(XkUserTypeTask::getTaskListByUserType($userInfo['userType'], $this->uid, $this->lang));
    }

    /**
     * 获取用户TXUSD记录
     */
    public function getTxUsdLog()
    {
        backSuccess(AssetFlow::getTxUsdLog($this->uid, $this->per, $this->lang));
    }
}